class Animal {
    public int age;
    public String name;

    public Animal (int age) {
        this.age = age;
    }

    public Animal (String name) {
        this.name = name;
        System.out.println ("父类的默认构造");
    }
}

class Dog extends Animal {
    //构造子类时，要先去构造父类，再构造子类

    //当代码中不存在上文的构造方法时，默认构造方法里面会提供一个类似于super（）的方法，所以不会报错
    public Dog (String s) {
        super (s);
    }
}

class A {

    static {
        System.out.println ("父类静态代码块 1");
    }

    {
        System.out.println ("父类代码块 2");
    }

    public int a = 1;
    public int b = 2;

    public A () {
        System.out.println ("父类的默认构造 3");
    }
}

// extends 表示 子类继承父类
class B extends A {
    static {
        System.out.println ("子类静态代码块 4");
    }

    {
        System.out.println ("子类代码块 5");
    }

    public int a = 4;
    public int b = 5;
    public int c = 3;

    public B () {
        System.out.println ("子类的默认构造 6");
    }

    public void method () {
        System.out.println (this.a);
        System.out.println (this.b);
        System.out.println (this.c);
        //super 用来访问父类里面与子类重复的
        System.out.println (super.a);
        System.out.println (super.b);
    }
}

public class Learn_4_29 {
    public static void main (String[] args) {
        //构建的顺序，先静态。然后先父类，后子类

        B b1 = new B ();
        System.out.println ("------------");
        B b2 = new B ();
    }

    public static void main1 (String[] args) {

        B b = new B ();
        b.method ();
    }

    public static void main2 (String[] args) {
        Dog dog = new Dog ("123");
    }

}
